import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '@/layout/index.vue'

export const constantRoutes: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import(/* webpackChunkName: "dashboard" */ '@/views/dashboard/index.vue'),
        meta: {
          title: 'Dashboard',
          icon: 'el-icon-eleme',
          affix: true // 固定显示在tagsView中，始终固定在开头不可删除
        }
      }
    ]
  }
]

export const asyncRoutes: Array<RouteRecordRaw> = [
  {
    path: '/documentation',
    component: Layout,
    redirect: '/documentation/index',
    children: [
      {
        path: 'index',
        name: 'Documentation',
        component: () => import(/* webpackChunkName: "documentation" */ '@/views/documentation/index.vue'),
        meta: {
          title: 'Documentation',
          icon: 'documentation',
          hidden: false
        }
      }
    ]
  },
  {
    path: '/guide',
    component: Layout,
    redirect: '/guide/index',
    children: [
      {
        path: 'index',
        name: 'Guide',
        component: () => import(/* webpackChunkName: "guide" */ '@/views/guide/index.vue'),
        meta: {
          title: 'Guide',
          icon: 'guide'
          // activeMenu: '/documentation/index' // 当前激活菜单高亮
        }
      }
    ]
  }
  // {
  //   path: '/system',
  //   component: Layout,
  //   // redirect: '/system/user',
  //   meta: {
  //     title: 'System',
  //     icon: 'lock',
  //     alwaysShow: true // 根路由始终显示 哪怕只有一个子路由
  //   },
  //   children: [
  //     {
  //       path: 'user',
  //       component: () => import(/* webpackChunkName: "user" */ '@/views/system/user.vue'),
  //       meta: {
  //         title: 'User Management',
  //         icon: 'list'
  //       }
  //     }
  //     // { // 外链路由
  //     //   path: '/external-link',
  //     //   component: Layout,
  //     //   children: [
  //     //     {
  //     //       path: 'https://www.baidu.com/',
  //     //       redirect: '/',
  //     //       meta: {
  //     //         title: 'External Link',
  //     //         icon: 'link'
  //     //       }
  //     //     }
  //     //   ]
  //     // }
  //   ]
  // }
]
export const routes = [
  ...constantRoutes, // 解构语法可能报波浪线tslib版本升级 没懂 暂时先不管
  ...asyncRoutes
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
